#ifndef HC_FILE_INFO_HC
#define HC_FILE_INFO_HC

#include <windows.h>
#pragma comment(lib, "version.lib")

#include <string>
using namespace std;

class hcFileInfo
{

public:
	static string getFileVersion(const char *filename)
	{
		string asVer = "";
		VS_FIXEDFILEINFO *pVsInfo;
		unsigned int iFileInfoSize = sizeof(VS_FIXEDFILEINFO);
		int iVerInfoSize = GetFileVersionInfoSizeA(filename, NULL); 
		if(iVerInfoSize != 0)
		{ 
			char *pBuf = NULL;

			while(!pBuf)
			{
				pBuf = new char[iVerInfoSize];
			}
			if(GetFileVersionInfoA(filename, 0, iVerInfoSize, pBuf))
			{ 
				if(VerQueryValueA(pBuf, "\\", (void **)&pVsInfo, &iFileInfoSize))
				{ 
					sprintf(pBuf, "%d.%d.%d.%d", HIWORD(pVsInfo->dwFileVersionMS), LOWORD(pVsInfo->dwFileVersionMS), HIWORD(pVsInfo->dwFileVersionLS), LOWORD(pVsInfo->dwFileVersionLS));
					asVer = pBuf; 
				} 
			} 
			delete pBuf;
		}
		return asVer;
	}
};


#endif
